package com.owulia.leetcode.num;

import java.util.HashMap;
import java.util.Map;

public class TargetSumOfTwoNumbers {

    public int[] twoSum(int[] numbers, int target) {
        Map<Integer, Integer> integerMap = new HashMap<>();
        for (int i = 0; i < numbers.length; i++) {
            Integer key = target - numbers[i];
            if (integerMap.containsKey(key)) {
                return new int[]{integerMap.get(key), i + 1};
            } else {
                integerMap.put(numbers[i], i + 1);
            }
        }
        return new int[]{};
    }
}
